package com.dymall.payment.controller;

import com.dymall.common.util.UserContext;
import com.dymall.payment.domain.dto.CreditCardInfo;
import com.dymall.payment.domain.pojo.CreditCard;
import com.dymall.payment.domain.dto.req.ChargeReq;
import com.dymall.payment.domain.dto.resp.ChargeResp;
import com.dymall.payment.service.impl.CreditCardServiceImpl;
import com.dymall.payment.service.impl.PaymentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/payment")
public class PaymentController {

    @Autowired
    private PaymentServiceImpl paymentService;

    @Autowired
    private CreditCardServiceImpl creditCardService;

    /**
     * 支付交易
     * @param req
     * @return
     */
    @PostMapping("/charge")
    public ChargeResp charge(@RequestBody ChargeReq req){
        return paymentService.charge(req);
    }

    /**
     * 绑定信用卡
     * @param cardInfo
     */
    @PutMapping("/card/bind")
    public void bindCreditCard(@RequestBody CreditCardInfo cardInfo){
        creditCardService.bindCreditCard(cardInfo);
    }
}
